package com.example.userdemo.demos;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.seata.core.context.RootContext;
import org.springframework.stereotype.Service;

/**
 * @ClassName: UserServiceImpl
 * @Description:
 * @Date 2024/01/29 13:07
 * @Author songshaoqiu
 **/
@Service
public class UserServiceImpl extends ServiceImpl<UserDao, User> implements UserService {
    @Override
    public User updateUser(String name) {
        System.out.println("事务id---------------------->" + RootContext.getXID());
        LambdaUpdateWrapper<User> updateWrapper = Wrappers.lambdaUpdate();
        updateWrapper.eq(User::getId,1);
        updateWrapper.set(User::getUserName,name);
        this.update(updateWrapper);
        User byId = this.getById(1);
        if (name.equals("aaa")){
            int i =1/0;
        }

        return byId;
    }
}
